define(['egis'], function (egis) {
    Window.deserializer = Window.deserializer || new egis.core.Deserializer();
    Window.container = Window.container || {};
    dsBridge.register('create_RestWRQSService', function (sourceId, url, http, authType, clientId, clientSecret,tokenUrl) {
        var restHttp = Window.container[http];
        var restGeoService = new egis.ews.RestWRQSService({
            url: url,
            http: restHttp,
            deserializer: Window.deserializer,
            authType: authType,
            clientId: clientId,
            clientSecret: clientSecret,
            tokenUrl:tokenUrl
        });
        Window.container[sourceId] = restGeoService;
    })

    dsBridge.registerAsyn('RestWRQSService_findAll', function (sourceId, wrqsPageQueryInput, responseCallback) {
        var restWRQSService = Window.container[sourceId];
        wrqsPageQueryInput = Window.deserializer.createJsInstance(JSON.parse(wrqsPageQueryInput));
        restWRQSService.findAll(wrqsPageQueryInput).then(function (value) {
            responseCallback(JSON.stringify(value));
        })
    })

    dsBridge.registerAsyn('RestWRQSService_findOne', function (sourceId, id, responseCallback) {
        var restWRQSService = Window.container[sourceId];
        restWRQSService.findOne(id).then(function (value) {
            responseCallback(JSON.stringify(value));
        })
    })

    dsBridge.registerAsyn('RestWRQSService_find', function (sourceId, wrqsSpatialQueryInput, geometry, responseCallback) {
        var restWRQSService = Window.container[sourceId];
        wrqsSpatialQueryInput = Window.deserializer.createJsInstance(JSON.parse(wrqsSpatialQueryInput));
        geometry = Window.deserializer.createJsInstance(JSON.parse(geometry));
        restWRQSService.find(wrqsSpatialQueryInput, geometry).then(function (value) {
            responseCallback(JSON.stringify(value));
        })
    })
})